///<reference path="../../typings/index.d.ts"/>
import requestManager = require("./APIRequestManager");
import { User } from "../ResponseModel/User";
import { APIRequestType, RequestMethod } from "../Core/FMAppAPIConstant";
import { ReqeustManager } from "./APIRequestManager";
import { FMAppUtils } from "../Utils/FMAppUtils";
import { LoginResult } from "../ResponseModel/LoginReuslt";

export class FMAppAPI {
    public  async login(account:string,password:string):Promise<LoginResult>{
        const promise = new Promise<LoginResult>( async (callback)=>{
             const api = new ReqeustManager<LoginResult>();
             password = FMAppUtils.desEncry(password);
             let reuqestObject = {
                account : account,
                password : password
             };
             const result =  await api.Request(APIRequestType.LoginType,RequestMethod.POST,reuqestObject);
             console.log(result.data.token);
             callback(result);
        });
        return promise;
    }
}
